package game.players;

import com.uqbar.vainilla.DeltaState;

import game.Goal3;
import game.components.UserPlayerMark;
import game.components.WorldSprite;
import game.players.states.PlayerState;
import game.players.states.WithBall;
import game.soccerField.Arc;

public abstract class SoccerPlayer extends WorldSprite {
	
	private double movementSpeed    = Goal3.PLAYER_SPEED;
	private int feetHeight          = 10;
	private int feetWidth           = 10;
	private boolean chasingTheBall  = false;
	private boolean withPlayingMark = false;
	
	private PlayerState state;
	private Arc rivalArc;
	
	public SoccerPlayer(double x, double y) {
		super(x,y);
	}
	
	public boolean isWithBall() {
		return this.getState().isWithBall();
	}
	
	public void addUserPlayerMark() {
		this.getScene().removeUserPlayerMark();
		this.getScene().setUserPlayerMark(new UserPlayerMark(this));
		this.setWithPlayingMark(true);
	}
	
	public boolean isInRightDirection() {
		return this.getState().isRight();
	}
	
	@Override
	public void update(DeltaState deltaState) {
		this.getState().update(deltaState);
		super.update(deltaState);
	}
	
	public void loseTheBall() {
		((WithBall) this.state).loseTheBall();
	}
	
	public boolean isMateOf(SoccerPlayer player) {
		return this.isUserMate() && player.isUserMate() || !this.isUserMate() && !player.isUserMate(); 
	}
	
	public abstract void setRightAnimationWithSpeed(double meanTime);
	
	public abstract void setLeftAnimationWithSpeed(double meanTime);
	
	public abstract boolean isUserMate();
	
	public abstract boolean isGoalKeeper();
	
	
	


	public double getMovementSpeed() {
		return movementSpeed;
	}
	
	public PlayerState getState() {
		return state;
	}

	public void setState(PlayerState state) {
		this.state = state;

	}

	public void setRivalArc(Arc arc) {
		this.rivalArc = arc;				
	}
	
	public Arc getRivalArc() {
		return rivalArc;
	}

	public void setMovementSpeed(double movementSpeed) {
		this.movementSpeed = movementSpeed;
	}
	
	public int getFeetHeight() {
		return feetHeight;
	}
	
	public int getFeetWidth() {
		return feetWidth;
	}
	
	public boolean isChasingTheBall() {
		return chasingTheBall;
	}

	public void setChasingTheBall(boolean chasingTheBall) {
		this.chasingTheBall = chasingTheBall;
	}

	public abstract void throwOutTheBall();
		

	public boolean isWithPlayingMark() {
		return withPlayingMark;
	}

	public void setWithPlayingMark(boolean withPlayingMark) {
		this.withPlayingMark = withPlayingMark;
	}
	
}
